/**
 * 验证字符串是否全是数字
 */
export const strIsAllNumber = (str) => {
    str = String(str);
    for (let i = 0; i < str.length; i++) {
      if (!(str[i] >= '0' && str[i] <= '9')) return false;
    }
    return true;
  };
  
  /**
   * 验证金额是否全为数字或金额格式是否正确
   */
  export const isMoney = (str) => {
    str = String(str);
    //小数点个数
    let pointNum = 0;
    if (str[str.length - 1] === '.') return false;
    for (let i = 0; i < str.length; i++) {
      if (!(str[i] >= '0' && str[i] <= '9' || str[i] === '.')) return false;
      if (str[i] === '.') pointNum++;
      if (pointNum >= 2) return false;
    }
    return true;
  };
  
  
  /**
   * 验证是否正确保留两位小数点位数
   */
  export const isTwoPlaces = (str) => {
    str = String(str);
    for (let i = 0; i < str.length; i++) {
      if (str[i] === '.' && str.length - 1 - i >= 3) return false;
    }
    return true;
  };